home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 125 / Computer Shopper CD-ROM Issue 125 (1998-07)(Dennis Publishing).iso / Business / Dazzler / DAZZLER.Z / CWidgitAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-26  |  2.3 KB  |  94 lines

  1. import java.awt.Dimension;
  2. import java.awt.Graphics;
  3. import java.awt.Rectangle;
  4. import java.io.DataInputStream;
  5.  
  6. public class CWidgitAction extends CDisplayAction {
  7.    static final int CYCLE_AUTO = 1;
  8.    static final int CYCLE_COUNT = 2;
  9.    protected CWidgitList m_WidgitList = new CWidgitList();
  10.    protected CVarOrValue m_vvPlaySpeed = new CVarOrValue();
  11.    protected int m_nPlayCount;
  12.    protected int m_nFlags;
  13.    private int m_nLoopCounter;
  14.    private int m_lTime;
  15.    private long m_lNextStepTime;
  16.  
  17.    boolean DoAction() {
  18.       boolean var1 = false;
  19.       this.FreeObject();
  20.       Dimension var2 = this.m_WidgitList.Load();
  21.       if (this.m_WidgitList.GetLoadCount() > 0) {
  22.          this.m_lTime = 10 * this.m_vvPlaySpeed.GetValue();
  23.          CRect var3 = new CRect(((CDisplayAction)this).GetActualRect());
  24.          var3.width = Math.min(var3.width, var2.width);
  25.          var3.height = Math.min(var3.height, var2.height);
  26.          if (!((Rectangle)var3).equals(((CDisplayAction)this).GetDrawRect())) {
  27.             if (!((CDisplayAction)this).GetDrawRect().isEmpty()) {
  28.                Globals.thePresView.InvalidateOffScreenRect(((CDisplayAction)this).GetDrawRect());
  29.             }
  30.  
  31.             ((CDisplayAction)this).SetDrawRect(var3);
  32.             var1 = true;
  33.          }
  34.       }
  35.  
  36.       CDrawObj var4 = Globals.thePresView.AddDrawObject((CIconObject)this, 0, var1);
  37.       if (var4 != null) {
  38.          Globals.theAnimThread.AddAnimObject(var4);
  39.       }
  40.  
  41.       return true;
  42.    }
  43.  
  44.    void DrawObject(Graphics var1, int var2, CRect var3) {
  45.       this.m_WidgitList.Draw(var1, var3);
  46.    }
  47.  
  48.    boolean LoadFromFile(DataInputStream var1) {
  49.       this.m_nFlags = FileLoad.ReadCPlusInt(var1);
  50.       this.m_nPlayCount = FileLoad.ReadCPlusInt(var1);
  51.       this.m_vvPlaySpeed.LoadFromFile(var1);
  52.       this.m_WidgitList.LoadFromFile(var1);
  53.       return super.LoadFromFile(var1);
  54.    }
  55.  
  56.    void FreeObject() {
  57.       this.m_nLoopCounter = 0;
  58.       this.m_lTime = 0;
  59.       this.m_lNextStepTime = 0L;
  60.    }
  61.  
  62.    boolean DoAnimation(CRect var1, long var2) {
  63.       boolean var4 = this.m_lTime != 0;
  64.       if (this.m_lTime != 0 && this.m_lNextStepTime <= System.currentTimeMillis() && var1 != null) {
  65.          if (this.m_lNextStepTime == 0L) {
  66.             this.m_lNextStepTime = Globals.theAnimThread.GetLoopStartTime() + (long)this.m_lTime;
  67.          } else {
  68.             this.m_lNextStepTime += (long)this.m_lTime;
  69.          }
  70.  
  71.          if (this.m_WidgitList.Increment()) {
  72.             ++this.m_nLoopCounter;
  73.             if ((this.m_nFlags & 2) != 0 && this.m_nLoopCounter >= this.m_nPlayCount) {
  74.                this.m_lTime = 0;
  75.                var4 = false;
  76.             }
  77.          }
  78.  
  79.          if (this.m_lTime != 0) {
  80.             CRect var5 = new CRect(var1);
  81.             Globals.thePresView.Render(var5);
  82.             Globals.thePresView.Draw((Graphics)null, var5);
  83.          }
  84.       }
  85.  
  86.       return var4;
  87.    }
  88.  
  89.    public CWidgitAction() {
  90.       super(28);
  91.       ((CDisplayAction)this).SetZOrder((short)4);
  92.    }
  93. }
  94.